/*
 * @Author: Setsuna
 * @Email: setsuna.xyz@qq.com
 * @FilePath: \src\components\UdFormControls\UdRadioGroup\index.tsx
 * @Date: 2022-12-05 10:44:43
 * @LastEditTime: 2023-02-23 12:19:06
 * @LastEditors: Setsuna
 */
import React, { forwardRef } from 'react'
import { Radio } from 'antd'

const UdRadioGroup = forwardRef((props:IUdRadioGroupProps,ref:React.Ref<any>|undefined)=> {
  const { options=[] } = props
  return (
    <Radio.Group onChange={props.onChange} value={props.value}  ref={ref}>
      {options.map(({value,title})=>(<Radio key={value} value={value}>{title}</Radio>))}
    </Radio.Group>
  )
})

export default UdRadioGroup

interface IUdRadioGroupProps {
  options?: {value:string|number,title:string}[]
  /** 此属性不用手动传 */
  value?: any
  /** 此属性不用手动传 */
  onChange?(e: any): void
}